import { reqPagesData , reqNavWapList} from "@/api"

const state = {
  pagesList:[],
  navWapList:[],
}
const mutations = {
  SET_PAGESLIST(state,pagesList){
    state.pagesList = pagesList
  },
  SET_NAVWAPLIST(state,navWapList){
      state.navWapList = navWapList
  }
}
const actions = {
  async getPagesData({commit},{page,size}){
    const result = await reqPagesData(page,size)
    commit('SET_PAGESLIST',result.data.result)
  },
  async getNavWapList({commit}){
    const result = await reqNavWapList()
    commit('SET_NAVWAPLIST',result.data.navList)
  },

}
const getters = {
    navList(state){
        let oneList = state.navWapList
        let lg = oneList.length
        let arr = []
        for(let i = 0;i< lg/2 ;i++){
          arr.push([oneList[i],oneList[i+7]])
        }
        return arr
    },
}
export default {
  state,
  mutations,
  actions,
  getters
}